using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using SharpWars.Core.Network;

namespace SharpWars.Core.Forms
{
	public partial class ConnectionForm : Form
	{
		public ConnectionForm()
		{
			InitializeComponent();
		}
		
		public string LocalIP
		{
			get
			{
				return this.localIPComboBox.SelectedItem as string;
			}
		}
		
		public int LocalPort
		{
			get
			{
				return int.Parse( this.localPortTextBox.Text );
			}
		}
		
		public string ServerIP
		{
			get
			{
				return this.serverIPTextBox.Text;
			}
		}
		
		public int ServerPort
		{
			get
			{
				return int.Parse( this.serverPortTextBox.Text );
			}
		}
		
		public string NickName
		{
			get
			{
				return this.nickNameTextBox.Text;
			}
		}

		private void OnConnectClick( object sender, EventArgs e )
		{
			DialogResult = DialogResult.OK;
		}

		private void OnLoad( object sender, EventArgs e )
		{
			foreach( IPAddress address in Dns.GetHostAddresses( Dns.GetHostName() ) )
			{
				this.localIPComboBox.Items.Add( address.ToString() );
			}
			
			#if( DEBUG )
			
			this.localIPComboBox.Items.Add( "127.0.0.1" );
			
			#endif
			
			this.localIPComboBox.SelectedIndex = 0;
		}
	}
}